From fbfa8bdeca38bd703f81eba2e086341c764bb116 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 18 Jun 2014 13:14:56 -0700 Subject: [PATCH] Make CARGO_BIN_PATH optional for tests This allows easier use of running tests by hand. --- Makefile | 2 +- tests/support/mod.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 256ef9cf9..216af20e0 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ test-unit: target/tests/test-unit target/tests/test-unit $(only) test-integration: target/tests/test-integration - RUST_TEST_TASKS=1 CARGO_BIN_PATH=$(PWD)/target/ $< $(only) + RUST_TEST_TASKS=1 $< $(only) test: test-unit test-integration diff --git a/tests/support/mod.rs b/tests/support/mod.rs index a976a158d..d045beb8a 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -163,9 +163,11 @@ impl ErrMsg for Result { // Path to cargo executables pub fn cargo_dir() -> Path { - os::getenv("CARGO_BIN_PATH") - .map(|s| Path::new(s)) - .unwrap_or_else(|| fail!("CARGO_BIN_PATH wasn't set. Cannot continue running test")) + os::getenv("CARGO_BIN_PATH").map(Path::new) + .or_else(|| os::self_exe_path().map(|p| p.dir_path())) + .unwrap_or_else(|| { + fail!("CARGO_BIN_PATH wasn't set. Cannot continue running test") + }) } /// Returns an absolute path in the filesystem that `path` points to. The -- 2.30.2